﻿using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;

namespace Inovout
{
    class Program
    {
        [STAThread()]
        static void Main(string[] args)
        {
#if DEBUG
          //  WpfApplicationHost.Run(true);
#else
            WpfApplicationHost.Run();
#endif
         }

        static void InitializeCompoent(Assembly[] frameworkAssemblies, Assembly[] moduleAssemblies)
        {
            Assembly coreAssembly = frameworkAssemblies.Single(assembly => assembly.GetName().Name.Equals("Inovout.Core"));
            MethodInfo entryPointMethodInfo = coreAssembly.GetType("Inovout.ComponentManager").GetMethod("Initialize");
            entryPointMethodInfo.Invoke(null, new object[] { frameworkAssemblies, moduleAssemblies });

        }


        static void RunWpfApplication(Assembly wpfApplicationAssembly)
        {
            MethodInfo entryPointMethodInfo = wpfApplicationAssembly.GetType("Inovout.Gui.Wpf.WpfApplicationHost").GetMethod("Run", BindingFlags.Public | BindingFlags.Static, null, new Type[] { typeof(string), typeof(string) }, null);
            entryPointMethodInfo.Invoke(null, new object[] { "Library", "Module" });
        }
        static Assembly[] LoadAssemblies(string assemblyFolder)
        {
            if (!Directory.Exists(assemblyFolder))
            {
                return null;
            }
            List<Assembly> assemblies = new List<Assembly>();
            foreach (string assemblyFile in Directory.GetFiles(assemblyFolder, "*.dll"))
            {
                AssemblyName applicationAssemblyName = AssemblyName.GetAssemblyName(assemblyFile);
                assemblies.Add(Assembly.Load(applicationAssemblyName));
            }
            return assemblies.ToArray();
        }
    }
}
